//package cn.itsource.ymcc.mq;
//
//import cn.itsource.ymcc.doc.CourseDoc;
//import cn.itsource.ymcc.domain.Course;
//import cn.itsource.ymcc.domain.MessageEmail;
//import cn.itsource.ymcc.util.EmailUtil;
//import com.alibaba.fastjson.JSONObject;
//import lombok.extern.log4j.Log4j;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.rocketmq.common.message.MessageExt;
//import org.apache.rocketmq.spring.annotation.MessageModel;
//import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
//import org.apache.rocketmq.spring.core.RocketMQListener;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.nio.charset.StandardCharsets;
//
//@Slf4j
//@Component
//@RocketMQMessageListener(
//        consumerGroup="service-course-consumer",//消费者组
//        topic="email",//topic
//        selectorExpression="course",//tags
//        messageModel= MessageModel.CLUSTERING//集群模式，一个消息只会给到一个消费者
//        //还有一个广播模式，一个消息可以被多个消费者消费
//)
//public class EmailConsumer implements RocketMQListener<MessageExt> {
//
//    @Autowired
//    private EmailUtil emailUtil;
//
//    @Override
//    @Transactional
//    public void onMessage(MessageExt messageExt) {
//        String message = new String(messageExt.getBody(), StandardCharsets.UTF_8);
//        log.info("消费者:"+ message);
//        MessageEmail messageEmail = JSONObject.parseObject(message, MessageEmail.class);
//        emailUtil.sendPassEmail(messageEmail);
//        log.info("消费者处理完成");
//
//    }
//}
